home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
414_01
/
comm5.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-06
|
30KB
|
982 lines
/***********************************************************************/
/* COMM5.C - Commands T-Z */
/* This file contains all commands that can be assigned to function */
/* keys or typed on the command line. */
/***********************************************************************/
/*
* THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
* Copyright (C) 1991-1993 Mark Hessling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
*
* The Free Software Foundation, Inc.
* 675 Mass Ave,
* Cambridge, MA 02139 USA.
*
*
* If you make modifications to this software that you feel increases
* it usefulness for the rest of the community, please email the
* changes, enhancements, bug fixes as well as any and all ideas to me.
* This software is going to be maintained and enhanced as deemed
* necessary by the community.
*
* Mark Hessling email: M.Hessling@gu.edu.au
* 36 David Road Phone: +61 7 849 7731
* Holland Park Fax: +61 7 875 5314
* QLD 4121
* Australia
*/
/*
$Header: C:\THE\RCS\comm5.c 1.4 1993/09/01 16:25:46 MH Interim MH $
*/
#include <stdio.h>
#include "the.h"
#include "proto.h"
/*#define DEBUG 1*/
/*-------------------------- external data ----------------------------*/
extern LINE *next_line,*curr_line;
extern VIEW_DETAILS *vd_current,*vd_first;
extern char current_screen;
extern SCREEN_DETAILS screen[MAX_SCREENS]; /* screen structures */
extern char current_file; /* pointer to current file */
extern WINDOW *foot,*error_window;
extern bool error_on_screen;
extern char *rec;
extern unsigned short rec_len;
extern char *cmd_rec;
extern unsigned short cmd_rec_len;
extern char mode_insert; /* defines insert mode toggle */
/*man-start*********************************************************************
COMMAND
tabcmd - switch windows (main/prefix command) for the current file
SYNTAX
TABCmd
** effective only if bound to a key **
DESCRIPTION
The TABCMD command switches the focus of the editor from the
main or prefix windows to the command line and vice versa, depending
on which window is currently active.
COMPATIBILITY
XEDIT: Equivalent of CURSOR HOME.
KEDIT: Equivalent of CURSOR HOME.
SEE ALSO
tabpre
STATUS
Complete. Will be replaced by CURSOR HOME in the future.
**man-end**********************************************************************/
#ifdef PROTO
int Tabcmd(char *params)
#else
int Tabcmd(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
char last_win;
unsigned short x,y;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm5.c: Tabcmd");
#endif
last_win = CURRENT_VIEW->previous_window;
CURRENT_VIEW->previous_window =
CURRENT_VIEW->current_window;
if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
{
post_process_line(CURRENT_VIEW->focus_line);
CURRENT_VIEW->current_window = WINDOW_COMMAND;
wmove(CURRENT_WINDOW,0,0);
}
else
{
pre_process_line(CURRENT_VIEW->focus_line);
CURRENT_VIEW->current_window = last_win;
getyx(CURRENT_WINDOW,y,x);
y = get_row_for_focus_line(CURRENT_VIEW->current_row,
CURRENT_VIEW->focus_line,
CURRENT_VIEW->current_line);
wmove(CURRENT_WINDOW,y,x);
}
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
tabpre - switch windows (main/prefix) for the current file
SYNTAX
TABPre
** effective only if bound to a key **
DESCRIPTION
The TABPRE command switches the focus of the editor from the
main window to the prefix window and vice versa, depending
on which window is currently active.
COMPATIBILITY
XEDIT: N/A
KEDIT: Equivalent of SOS LEFTEDGE and SOS PREFIX
SEE ALSO
tabcmd
STATUS
Complete.
**man-end**********************************************************************/
#ifdef PROTO
int Tabpre(char *params)
#else
int Tabpre(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
char last_win;
unsigned short y,x;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm5.c: Tabpre");
#endif
/*---------------------------------------------------------------------*/
/* If the cursor is in the command line or there is no prefix on, exit.*/
/*---------------------------------------------------------------------*/
if (CURRENT_VIEW->current_window == WINDOW_COMMAND
|| !CURRENT_VIEW->prefix)
{
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
}
getyx(CURRENT_WINDOW,y,x);
last_win = CURRENT_VIEW->previous_window;
CURRENT_VIEW->previous_window =
CURRENT_VIEW->current_window;
if (CURRENT_VIEW->current_window == WINDOW_MAIN)
{
post_process_line(CURRENT_VIEW->focus_line);
CURRENT_VIEW->current_window = WINDOW_PREFIX;
}
else
{
pre_process_line(CURRENT_VIEW->focus_line);
CURRENT_VIEW->current_window = WINDOW_MAIN;
}
wmove(CURRENT_WINDOW,y,0);
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
text - simulate keyboard entry of characters
SYNTAX
TEXT text
DESCRIPTION
The TEXT command simulates the entry of characters from the
keyboard. This command is actually called when you enter text
from the keyboard.
COMPATIBILITY
XEDIT: N/A
KEDIT: Compatible.
Does not allow leading or trailing spaces in text (at the
moment)
STATUS
Complete.
**man-end**********************************************************************/
#ifdef PROTO
int Text(char *params)
#else
int Text(params)
char *params;
#endif
/***********************************************************************/
{
/*------------------------- external data -----------------------------*/
extern bool extended_display_mode;
extern bool CMDARROWSTABLRx;
extern bool prefix_changed;
extern char *pre_rec;
extern unsigned short pre_rec_len;
/*--------------------------- local data ------------------------------*/
register int i;
char real_key;
chtype chtype_key;
unsigned short y,x;
bool save_CMDARROWSTABLRx;
int len_params;
int rc;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm5.c: Text");
#endif
/*---------------------------------------------------------------------*/
/* If no parameters, return without doing anything. */
/*---------------------------------------------------------------------*/
save_CMDARROWSTABLRx = CMDARROWSTABLRx;
if (CURRENT_VIEW->hex == ON)
{
if ((len_params = convert_hex_strings(params)) == (-1))
{
display_error(32,(char *)"");
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
}
else
len_params = strlen(params);
for (i=0;i<len_params;i++)
{
real_key = case_translate((char)*(params+i));
chtype_key = (chtype)(real_key & A_CHARTEXT);
switch(CURRENT_VIEW->current_window)
{
case WINDOW_MAIN:
if (CURRENT_VIEW->focu